package com.work.wrapper.bd;

import com.work.entity.bd.BdTeam;
import com.work.vo.bd.BdTeamTreeVO;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.BeanUtil;

import java.util.List;
import java.util.Objects;

/**
 * 队组树形包装类
 *
 * @author ：dujianyu
 * @since ：Created in 2024/5/20 9:07
 */
public class BdTeamTreeWrapper extends BaseEntityWrapper<BdTeam, BdTeamTreeVO> {
    public static BdTeamTreeWrapper build() {
        return new BdTeamTreeWrapper();
    }

    @Override
    public BdTeamTreeVO entityVO(BdTeam entity) {
        BdTeamTreeVO treeVO = Objects.requireNonNull(BeanUtil.copy(entity, BdTeamTreeVO.class));
        treeVO.setValue(treeVO.getTransportCorpId().toString() + "-" + treeVO.getName());
        treeVO.setText(treeVO.getName());
        return treeVO;
    }

    public List<BdTeamTreeVO> listNodeVO(List<BdTeam> list) {
        List<BdTeamTreeVO> collect = listVO(list);
        return ForestNodeMerger.merge(collect);
    }
}
